home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / dkbsrc.zip / FRAME.H < prev    next >
C/C++ Source or Header  |  1991-05-04  |  21KB  |  760 lines

  1. /*****************************************************************************
  2. *
  3. *                                   frame.h
  4. *
  5. *   from DKBTrace (c) 1990  David Buck
  6. *
  7. *  This header file is included by all C modules in DKBTrace.  It defines all
  8. *  globally-accessible types and constants.
  9. *
  10. * This software is freely distributable. The source and/or object code may be
  11. * copied or uploaded to communications services so long as this notice remains
  12. * at the top of each file.  If any changes are made to the program, you must
  13. * clearly indicate in the documentation and in the programs startup message
  14. * who it was who made the changes. The documentation should also describe what
  15. * those changes were. This software may not be included in whole or in
  16. * part into any commercial package without the express written consent of the
  17. * author.  It may, however, be included in other public domain or freely
  18. * distributed software so long as the proper credit for the software is given.
  19. *
  20. * This software is provided as is without any guarantees or warranty. Although
  21. * the author has attempted to find and correct any bugs in the software, he
  22. * is not responsible for any damage caused by the use of the software.  The
  23. * author is under no obligation to provide service, corrections, or upgrades
  24. * to this package.
  25. *
  26. * Despite all the legal stuff above, if you do find bugs, I would like to hear
  27. * about them.  Also, if you have any comments or questions, you may contact me
  28. * at the following address:
  29. *
  30. *     David Buck
  31. *     22C Sonnet Cres.
  32. *     Nepean Ontario
  33. *     Canada, K2H 8W7
  34. *
  35. *  I can also be reached on the following bulleton boards:
  36. *
  37. *     OMX              (613) 731-3419
  38. *     Mystic           (613) 596-4249  or  (613) 596-4772
  39. *
  40. *  Fidonet:   1:163/109.9
  41. *  Internet:  dbuck@ccs.carleton.ca
  42. *  The "You Can Call Me RAY" BBS    (708) 358-5611
  43. *
  44. *  IBM Port by Aaron A. Collins. Aaron may be reached on the following BBS'es:
  45. *
  46. *     The "You Can Call Me RAY" BBS (708) 358-5611
  47. *     The Information Exchange BBS  (708) 945-5575
  48. *
  49. *****************************************************************************/
  50.  
  51.  
  52. /* Generic header for all modules */
  53.  
  54. #include <stdio.h>
  55. #include <string.h>
  56. #include <math.h>
  57. #include "config.h"
  58.  
  59. #ifndef TRUE
  60. #define TRUE 1
  61. #define FALSE 0
  62. #endif
  63.  
  64. #ifndef FILE_NAME_LENGTH
  65. #define FILE_NAME_LENGTH 150
  66. #endif
  67.  
  68. #ifndef DBL
  69. #define DBL double
  70. #endif
  71.  
  72. #ifndef HUGE_VAL
  73. #define HUGE_VAL 1.0e+17
  74. #endif
  75.  
  76. #ifndef DBL_FORMAT_STRING
  77. #define DBL_FORMAT_STRING "%lf"
  78. #endif
  79.  
  80. #ifndef DEFAULT_OUTPUT_FORMAT
  81. #define DEFAULT_OUTPUT_FORMAT    'd'
  82. #endif
  83.  
  84. #ifndef TEST_ABORT
  85. #define TEST_ABORT
  86. #endif
  87.  
  88. #ifndef RED_RAW_FILE_EXTENSION
  89. #define RED_RAW_FILE_EXTENSION ".red"
  90. #endif
  91.  
  92. #ifndef GREEN_RAW_FILE_EXTENSION
  93. #define GREEN_RAW_FILE_EXTENSION ".grn"
  94. #endif
  95.  
  96. #ifndef BLUE_RAW_FILE_EXTENSION
  97. #define BLUE_RAW_FILE_EXTENSION ".blu"
  98. #endif
  99.  
  100. #ifndef STARTUP_DKB_TRACE
  101. #define STARTUP_DKB_TRACE
  102. #endif
  103.  
  104. #ifndef PRINT_OTHER_CREDITS
  105. #define PRINT_OTHER_CREDITS
  106. #endif
  107.  
  108. #ifndef FINISH_DKB_TRACE
  109. #define FINISH_DKB_TRACE
  110. #endif
  111.  
  112. #ifndef FILENAME_SEPARATOR
  113. #define FILENAME_SEPARATOR "/"
  114. #endif
  115.  
  116. /* These values determine the minumum and maximum distances
  117.    that qualify as ray-object intersections */
  118. #define Small_Tolerance 0.001
  119. #define Max_Distance 1.0e7
  120.  
  121. typedef struct q_entry INTERSECTION;
  122. typedef struct Vector_Struct VECTOR;
  123. typedef DBL MATRIX [4][4];
  124. typedef struct Colour_Struct COLOUR;
  125. typedef struct Colour_Map_Entry COLOUR_MAP_ENTRY;
  126. typedef struct Colour_Map_Struct COLOUR_MAP;
  127. typedef struct Transformation_Struct TRANSFORMATION;
  128. typedef struct Image_Struct IMAGE;
  129. typedef struct Texture_Struct TEXTURE;
  130. typedef struct Method_Struct METHODS;
  131. typedef struct Viewpoint_Struct VIEWPOINT;
  132. typedef struct Object_Shape SHAPE;
  133. typedef struct Object_Struct OBJECT;
  134. typedef struct Sphere_Shape SPHERE;
  135. typedef struct Quadric_Shape QUADRIC;
  136. typedef struct Quartic_Shape QUARTIC;
  137. typedef struct Triangle_Shape TRIANGLE;
  138. typedef struct Smooth_Triangle_Shape SMOOTH_TRIANGLE;
  139. typedef struct Plane_Shape PLANE;
  140. typedef struct CSG_Type CSG_SHAPE;
  141. typedef struct Composite_Object_Struct COMPOSITE;
  142. typedef struct Ray_Struct RAY;
  143. typedef struct Frame_Struct FRAME;
  144. typedef struct prioq_struct PRIOQ;
  145. typedef int TOKEN;
  146. typedef int CONSTANT;
  147. typedef struct Chunk_Header_Struct CHUNK_HEADER;
  148. typedef struct Data_File_Struct DATA_FILE;
  149. typedef struct complex_block complex;
  150.  
  151. struct Vector_Struct
  152.    {
  153.    DBL x, y, z;
  154.    };
  155.  
  156.  
  157.  
  158. struct Colour_Struct
  159.    {
  160.    DBL Red, Green, Blue, Alpha;
  161.    };
  162.  
  163.  
  164. struct Colour_Map_Entry
  165.    {
  166.    DBL start, end;
  167.    COLOUR Start_Colour, End_Colour;
  168.    };
  169.  
  170.  
  171. struct Colour_Map_Struct
  172.    {
  173.    int Number_Of_Entries;
  174.    COLOUR_MAP_ENTRY *Colour_Map_Entries;
  175.    int Transparency_Flag;
  176.    };
  177.  
  178.  
  179. struct Transformation_Struct
  180.    {
  181.    MATRIX matrix;
  182.    MATRIX inverse;
  183.    };
  184.  
  185.  
  186. /* Types for reading IFF files. */
  187. typedef struct {
  188.    unsigned short Red, Green, Blue, Alpha;
  189.    } IMAGE_COLOUR;
  190.  
  191. struct Image_Line
  192.    {
  193.    unsigned char *red, *green, *blue;
  194.    };
  195.  
  196. typedef struct Image_Line IMAGE_LINE;
  197.  
  198. struct Image_Struct
  199.    {
  200.    DBL width, height;
  201.    int iwidth, iheight;
  202.    short Colour_Map_Size;
  203.    IMAGE_COLOUR *Colour_Map;
  204.    union {
  205.       IMAGE_LINE *rgb_lines;
  206.       unsigned char **map_lines;
  207.       } data;
  208.    };
  209.  
  210.  
  211. #define NO_TEXTURE               0
  212. #define COLOUR_TEXTURE           1
  213. #define BOZO_TEXTURE             2
  214. #define MARBLE_TEXTURE           3
  215. #define WOOD_TEXTURE             4
  216. #define CHECKER_TEXTURE          5
  217. #define CHECKER_TEXTURE_TEXTURE  6
  218. #define SPOTTED_TEXTURE          7
  219. #define AGATE_TEXTURE            8
  220. #define GRANITE_TEXTURE          9
  221. #define GRADIENT_TEXTURE        10
  222. #define IMAGEMAP_TEXTURE        11
  223.  
  224. #define NO_BUMPS   0
  225. #define WAVES      1
  226. #define RIPPLES    2
  227. #define WRINKLES   3
  228. #define BUMPS      4
  229. #define DENTS      5
  230.  
  231. struct Texture_Struct
  232.    {
  233.    TEXTURE *Next_Texture;
  234.    DBL Object_Reflection;
  235.    DBL Object_Ambient;
  236.    DBL Object_Diffuse, Object_Brilliance;
  237.    DBL Object_Index_Of_Refraction;
  238.    DBL Object_Refraction;
  239.    DBL Object_Specular, Object_Roughness;
  240.    DBL Object_Phong, Object_PhongSize;
  241.    DBL Bump_Amount;
  242.    DBL Texture_Randomness;
  243.    DBL Frequency;
  244.    DBL Phase;
  245.    int Texture_Number ;
  246.    int Bump_Number;
  247.    TRANSFORMATION *Texture_Transformation;
  248.    COLOUR *Colour1;
  249.    COLOUR *Colour2;
  250.    DBL Turbulence;
  251.    VECTOR Texture_Gradient;
  252.    COLOUR_MAP *Colour_Map;
  253.    IMAGE *Image;
  254.    short Metallic_Flag, Once_Flag, Constant_Flag;
  255.    };
  256.  
  257. #define SPHERE_TYPE            0
  258. #define TRIANGLE_TYPE          1
  259. #define SMOOTH_TRIANGLE_TYPE   2
  260. #define PLANE_TYPE             3
  261. #define QUADRIC_TYPE           4
  262. #define QUARTIC_TYPE           5
  263. #define COMPOSITE_TYPE         6
  264. #define OBJECT_TYPE            7
  265. #define CSG_UNION_TYPE         8
  266. #define CSG_INTERSECTION_TYPE  9
  267. #define CSG_DIFFERENCE_TYPE   10
  268. #define VIEWPOINT_TYPE        11
  269.  
  270. struct Object_Struct
  271.    {
  272.    METHODS *Methods;
  273.    int Type;
  274.    struct Object_Struct *Next_Object;
  275.    struct Object_Struct *Next_Light_Source;
  276.    SHAPE *Bounding_Shapes;
  277.    SHAPE *Shape;
  278.    char Light_Source_Flag;
  279.    VECTOR  Object_Center;
  280.    COLOUR *Object_Colour;
  281.    TEXTURE *Object_Texture;
  282.    };
  283.  
  284.  
  285. typedef INTERSECTION *(*INTERSECTION_METHOD)PARAMS((OBJECT *, RAY *));
  286. typedef int (*ALL_INTERSECTIONS_METHOD)PARAMS((OBJECT *, RAY *, PRIOQ *));
  287. typedef int (*INSIDE_METHOD)PARAMS((VECTOR *, OBJECT *));
  288. typedef void (*NORMAL_METHOD)PARAMS((VECTOR *, OBJECT *, VECTOR *));
  289. typedef void *(*COPY_METHOD)PARAMS((OBJECT *));
  290. typedef void (*TRANSLATE_METHOD)PARAMS((OBJECT *, VECTOR *));
  291. typedef void (*ROTATE_METHOD)PARAMS((OBJECT *, VECTOR *));
  292. typedef void (*SCALE_METHOD)PARAMS((OBJECT *, VECTOR *));
  293. typedef void (*INVERT_METHOD)PARAMS((OBJECT *));
  294.  
  295. struct Method_Struct
  296.    {
  297.    INTERSECTION_METHOD Intersection_Method;
  298.    ALL_INTERSECTIONS_METHOD All_Intersections_Method;
  299.    INSIDE_METHOD Inside_Method;
  300.    NORMAL_METHOD Normal_Method;
  301.    COPY_METHOD Copy_Method;
  302.    TRANSLATE_METHOD Translate_Method;
  303.    ROTATE_METHOD Rotate_Method;
  304.    SCALE_METHOD Scale_Method;
  305.    INVERT_METHOD Invert_Method;
  306.    };
  307.  
  308.  
  309. #define All_Intersections(x,y,z) ((*((x)->Methods->All_Intersections_Method)) (x,y,z))
  310. #define Intersection(x,y) ((INTERSECTION *) ((*((x)->Methods->Intersection_Method)) (x,y)))
  311. #define Inside(x,y) ((*((y)->Methods->Inside_Method)) (x,y))
  312. #define Normal(x,y,z) ((*((y)->Methods->Normal_Method)) (x,y,z))
  313. #define Copy(x) ((*((x)->Methods->Copy_Method)) (x))
  314. #define Translate(x,y) ((*((x)->Methods->Translate_Method)) (x,y))
  315. #define Scale(x,y) ((*((x)->Methods->Scale_Method)) (x,y))
  316. #define Rotate(x,y) ((*((x)->Methods->Rotate_Method)) (x,y))
  317. #define Invert(x) ((*((x)->Methods->Invert_Method)) (x))
  318.  
  319. struct Viewpoint_Struct
  320.    {
  321.    METHODS *Methods;
  322.    int Type;
  323.    VECTOR Location;
  324.    VECTOR Direction;
  325.    VECTOR Up;
  326.    VECTOR Right;
  327.    VECTOR Sky;
  328.    };
  329.  
  330.  
  331. struct Object_Shape
  332.    {
  333.    METHODS *Methods;
  334.    int Type;
  335.    struct Object_Shape *Next_Object;
  336.    void *Parent_Object;
  337.    TEXTURE *Shape_Texture;
  338.    COLOUR *Shape_Colour;
  339.    };
  340.  
  341.  
  342. struct Sphere_Shape
  343.    {
  344.    METHODS *Methods;
  345.    int Type;
  346.    SHAPE *Next_Object;
  347.    OBJECT *Parent_Object;
  348.    TEXTURE *Shape_Texture;
  349.    COLOUR *Shape_Colour;
  350.    VECTOR  Center;
  351.    DBL     Radius;
  352.    DBL     Radius_Squared;
  353.    DBL     Inverse_Radius;
  354.    VECTOR  VPOtoC;
  355.    DBL     VPOCSquared;
  356.    short   VPinside, VPCached, Inverted;
  357.    };
  358.  
  359.  
  360. struct Quadric_Shape
  361.    {
  362.    METHODS *Methods;
  363.    int Type;
  364.    SHAPE *Next_Object;
  365.    OBJECT *Parent_Object;
  366.    TEXTURE *Shape_Texture;
  367.    COLOUR *Shape_Colour;
  368.    VECTOR  Object_2_Terms;
  369.    VECTOR  Object_Mixed_Terms;
  370.    VECTOR  Object_Terms;
  371.    DBL Object_Constant;
  372.    DBL Object_VP_Constant;
  373.    int Constant_Cached;
  374.    int Non_Zero_Square_Term;
  375.    };
  376.  
  377. struct Quartic_Shape
  378.    {
  379.    METHODS *Methods;
  380.    int Type;
  381.    SHAPE *Next_Object;
  382.    OBJECT *Parent_Object;
  383.    TEXTURE *Shape_Texture;
  384.    COLOUR *Shape_Colour;
  385.    DBL Coeffs[35];
  386.    };
  387.  
  388. #define X_AXIS 0
  389. #define Y_AXIS 1
  390. #define Z_AXIS 2
  391.  
  392. struct Triangle_Shape
  393.    {
  394.    METHODS *Methods;
  395.    int Type;
  396.    SHAPE *Next_Object;
  397.    OBJECT *Parent_Object;
  398.    TEXTURE *Shape_Texture;
  399.    COLOUR *Shape_Colour;
  400.    VECTOR  Normal_Vector;
  401.    DBL     Distance;
  402.    DBL     VPNormDotOrigin;
  403.    unsigned int  VPCached:1;
  404.    unsigned int  Dominant_Axis:2;
  405.    unsigned int  Inverted:1;
  406.    unsigned int  vAxis:2;         /* used only for smooth triangles */
  407.    VECTOR  P1, P2, P3;
  408.    };
  409.  
  410.  
  411. struct Smooth_Triangle_Shape
  412.    {
  413.    METHODS *Methods;
  414.    int Type;
  415.    SHAPE *Next_Object;
  416.    OBJECT *Parent_Object;
  417.    TEXTURE *Shape_Texture;
  418.    COLOUR *Shape_Colour;
  419.    VECTOR  Normal_Vector;
  420.    DBL     Distance;
  421.    DBL     VPNormDotOrigin;
  422.    unsigned int  VPCached:1;
  423.    unsigned int  Dominant_Axis:2;
  424.    unsigned int  Inverted:1;
  425.    unsigned int  vAxis:2;         /* used only for smooth triangles */
  426.    VECTOR  P1, P2, P3;
  427.    VECTOR  N1, N2, N3, Perp;
  428.    DBL  BaseDelta;
  429.    };
  430.  
  431.  
  432.  
  433. struct Plane_Shape
  434.    {
  435.    METHODS *Methods;
  436.    int Type;
  437.    SHAPE *Next_Object;
  438.    OBJECT *Parent_Object;
  439.    TEXTURE *Shape_Texture;
  440.    COLOUR *Shape_Colour;
  441.    VECTOR  Normal_Vector;
  442.    DBL     Distance;
  443.    DBL     VPNormDotOrigin;
  444.    int     VPCached;
  445.    };
  446.  
  447.  
  448. struct CSG_Type
  449.    {
  450.    METHODS *Methods;
  451.    int Type;
  452.    SHAPE *Next_Object;
  453.    OBJECT *Parent_Object;
  454.    SHAPE *Shapes;
  455.    };
  456.    
  457.  
  458. struct Composite_Object_Struct
  459.    {
  460.    METHODS *Methods;
  461.    int Type;
  462.    OBJECT *Next_Object;
  463.    OBJECT *Next_Light_Source;
  464.    SHAPE *Bounding_Shapes;
  465.    OBJECT *Objects;
  466.    };
  467.  
  468.  
  469. #define MAX_CONTAINING_OBJECTS 10
  470.  
  471. struct Ray_Struct
  472.    {
  473.    VECTOR Initial;               /*  Xo  Yo  Zo  */
  474.    VECTOR Direction;             /*  Xv  Yv  Zv  */
  475.    VECTOR Initial_2;             /*  Xo^2  Yo^2  Zo^2  */
  476.    VECTOR Direction_2;           /*  Xv^2  Yv^2  Zv^2  */
  477.    VECTOR Initial_Direction;     /*  XoXv  YoYv  ZoZv  */
  478.    VECTOR Mixed_Initial_Initial; /*  XoYo  XoZo  YoZo  */
  479.    VECTOR Mixed_Dir_Dir;         /*  XvYv  XvZv  YvZv  */
  480.    VECTOR Mixed_Init_Dir;        /*  XoYv+XvYo  XoZv+XvZo  YoZv+YvZo  */
  481.    int Containing_Index;
  482.    TEXTURE *Containing_Textures [MAX_CONTAINING_OBJECTS];
  483.    DBL Containing_IORs [MAX_CONTAINING_OBJECTS];
  484.    int Quadric_Constants_Cached;
  485.    };
  486.  
  487.  
  488. struct Frame_Struct
  489.    {
  490.    VIEWPOINT View_Point;
  491.    int Screen_Height, Screen_Width;
  492.    OBJECT *Light_Sources;
  493.    OBJECT *Objects;
  494.    DBL Atmosphere_IOR, Antialias_Threshold;
  495.    DBL Fog_Distance;
  496.    COLOUR Fog_Colour;
  497.    };
  498.  
  499.  
  500. #define DISPLAY 1
  501. #define VERBOSE 2
  502. #define DISKWRITE 4
  503. #define PROMPTEXIT 8
  504. #define ANTIALIAS 16
  505. #define DEBUGGING 32
  506. #define RGBSEPARATE 64
  507. #define EXITENABLE 128
  508. #define CONTINUE_TRACE 256
  509.  
  510. #define Make_Colour(c,r,g,b) { (c)->Red=(r);(c)->Green=(g);(c)->Blue=(b); (c)->Alpha=0.0; }
  511.  
  512. #define Make_Vector(v,a,b,c) { (v)->x=(a);(v)->y=(b);(v)->z=(c); }
  513.  
  514. /* Definitions for PRIOQ structure */
  515.  
  516. struct q_entry
  517.    {
  518.    DBL Depth;
  519.    OBJECT *Object;
  520.    VECTOR Point;
  521.    SHAPE *Shape;
  522.    };
  523.  
  524. struct prioq_struct
  525.    {
  526.    struct prioq_struct *next_pq;
  527.    struct q_entry *queue;
  528.    unsigned int current_entry, queue_size;
  529.    };
  530.  
  531.  
  532. /* Token Definitions for Parser */
  533.  
  534. #define AGATE_TOKEN                  0
  535. #define ALL_TOKEN                    1
  536. #define ALPHA_TOKEN                  2
  537. #define AMBIENT_TOKEN                3
  538. #define AMPERSAND_TOKEN              4
  539. #define AT_TOKEN                     5
  540. #define BACK_QUOTE_TOKEN             6
  541. #define BACK_SLASH_TOKEN             7
  542. #define BAR_TOKEN                    8
  543. #define BLUE_TOKEN                   9
  544. #define BRILLIANCE_TOKEN            10
  545. #define BOZO_TOKEN                  11
  546. #define BOUNDED_TOKEN               12
  547. #define BUMPS_TOKEN                 13
  548. #define CHECKER_TOKEN               14
  549. #define CHECKER_TEXTURE_TOKEN       15
  550. #define COLON_TOKEN                 16
  551. #define COLOR_TOKEN                 17
  552. #define COLOUR_TOKEN                18
  553. #define COLOR_MAP_TOKEN             19
  554. #define COLOUR_MAP_TOKEN            20
  555. #define COMMA_TOKEN                 21
  556. #define COMPOSITE_TOKEN             22
  557. #define CONCENTRATION_TOKEN         23
  558. #define DASH_TOKEN                  24
  559. #define DECLARE_TOKEN               25
  560. #define DENTS_TOKEN                 26
  561. #define DIFFERENCE_TOKEN            27
  562. #define DIFFUSE_TOKEN               28
  563. #define DIRECTION_TOKEN             29
  564. #define DOLLAR_TOKEN                30
  565. #define DUMP_TOKEN                  31
  566. #define END_BOUNDED_TOKEN           32
  567. #define END_CHECKER_TEXTURE_TOKEN   33
  568. #define END_COLOR_MAP_TOKEN         34
  569. #define END_COLOUR_MAP_TOKEN        35
  570. #define END_COMPOSITE_TOKEN         36
  571. #define END_DIFFERENCE_TOKEN        37
  572. #define END_FOG_TOKEN               38
  573. #define END_INTERSECTION_TOKEN      39
  574. #define END_OBJECT_TOKEN            40
  575. #define END_OF_FILE_TOKEN           41
  576. #define END_PLANE_TOKEN             42
  577. #define END_POINTS_TOKEN            43
  578. #define END_POLYGON_TOKEN           44
  579. #define END_QUADRIC_TOKEN           45
  580. #define END_QUARTIC_TOKEN           46
  581. #define END_SHAPE_TOKEN             47
  582. #define END_SMOOTH_TRIANGLE_TOKEN   48
  583. #define END_SPHERE_TOKEN            49
  584. #define END_TEXTURE_TOKEN           50
  585. #define END_TRIANGLE_TOKEN          51
  586. #define END_UNION_TOKEN             52
  587. #define END_VIEW_POINT_TOKEN        53
  588. #define EQUALS_TOKEN                54
  589. #define EXCLAMATION_TOKEN           55
  590. #define FLOAT_TOKEN                 56
  591. #define FOG_TOKEN                   57
  592. #define FREQUENCY_TOKEN             58
  593. #define GIF_TOKEN                   59
  594. #define GRADIENT_TOKEN              60
  595. #define GRANITE_TOKEN               61
  596. #define GREEN_TOKEN                 62
  597. #define HASH_TOKEN                  63
  598. #define HAT_TOKEN                   64
  599. #define IDENTIFIER_TOKEN            65
  600. #define IFF_TOKEN                   66
  601. #define IMAGEMAP_TOKEN              67
  602. #define INCLUDE_TOKEN               68
  603. #define INTERSECTION_TOKEN          69
  604. #define INVERSE_TOKEN               70
  605. #define IOR_TOKEN                   71
  606. #define LEFT_ANGLE_TOKEN            72
  607. #define LEFT_BRACKET_TOKEN          73
  608. #define LEFT_SQUARE_TOKEN           74
  609. #define LIGHT_SOURCE_TOKEN          75
  610. #define LOCATION_TOKEN              76
  611. #define LOOK_AT_TOKEN               77
  612. #define MARBLE_TOKEN                78
  613. #define METALLIC_TOKEN              79
  614. #define OBJECT_TOKEN                80
  615. #define ONCE_TOKEN                  81
  616. #define PERCENT_TOKEN               82
  617. #define PHASE_TOKEN                 83
  618. #define PHONG_TOKEN                 84
  619. #define PHONGSIZE_TOKEN             85
  620. #define PLANE_TOKEN                 86
  621. #define PLUS_TOKEN                  87
  622. #define POINTS_TOKEN                88
  623. #define POINT_AT_TOKEN              89
  624. #define POLYGON_TOKEN               90
  625. #define QUADRIC_TOKEN               91
  626. #define QUARTIC_TOKEN               92
  627. #define QUESTION_TOKEN              93
  628. #define RAW_TOKEN                   94
  629. #define RED_TOKEN                   95
  630. #define REFLECTION_TOKEN            96
  631. #define REFRACTION_TOKEN            97
  632. #define REVOLVE_TOKEN               98
  633. #define RIGHT_TOKEN                 99
  634. #define RIGHT_ANGLE_TOKEN          100
  635. #define RIGHT_BRACKET_TOKEN        101
  636. #define RIGHT_SQUARE_TOKEN         102
  637. #define RIPPLES_TOKEN              103
  638. #define ROTATE_TOKEN               104
  639. #define ROUGHNESS_TOKEN            105
  640. #define SCALE_TOKEN                106
  641. #define SEMI_COLON_TOKEN           107
  642. #define SHAPE_TOKEN                108
  643. #define SINGLE_QUOTE_TOKEN         109
  644. #define SIZE_TOKEN                 110
  645. #define SKY_TOKEN                  111
  646. #define SLASH_TOKEN                112
  647. #define SMOOTH_TRIANGLE_TOKEN      113
  648. #define SPECULAR_TOKEN             114
  649. #define SPHERE_TOKEN               115
  650. #define SPOTLIGHT_TOKEN            116
  651. #define SPOTTED_TOKEN              117
  652. #define STAR_TOKEN                 118
  653. #define STRING_TOKEN               119
  654. #define TEXTURE_TOKEN              120
  655. #define TILDE_TOKEN                121
  656. #define TILE2_TOKEN                122
  657. #define TRANSLATE_TOKEN            123
  658. #define TRIANGLE_TOKEN             124
  659. #define TURBULENCE_TOKEN           125
  660. #define UNION_TOKEN                126
  661. #define UP_TOKEN                   127
  662. #define VIEW_POINT_TOKEN           128
  663. #define WAVES_TOKEN                129
  664. #define WOOD_TOKEN                 130
  665. #define WRINKLES_TOKEN             131
  666. #define LAST_TOKEN                 132
  667.  
  668.  
  669. struct Reserved_Word_Struct
  670.    {                                
  671.    TOKEN Token_Number;
  672.    char *Token_Name;
  673.    };
  674.  
  675. /* Here's where you dump the information on the current token (fm. PARSE.C) */
  676.  
  677. struct Token_Struct
  678.    {
  679.    TOKEN Token_Id;
  680.    int Token_Line_No;
  681.    char *Token_String;
  682.    DBL Token_Float;
  683.    int Identifier_Number;
  684.    int Unget_Token, End_Of_File;
  685.    char *Filename;
  686.    };
  687.  
  688. /* Types of constants allowed in DECLARE statement (fm. PARSE.C) */
  689.  
  690. #define OBJECT_CONSTANT            0
  691. #define VIEW_POINT_CONSTANT        1
  692. #define VECTOR_CONSTANT            2
  693. #define FLOAT_CONSTANT             3
  694. #define COLOUR_CONSTANT            4
  695. #define QUADRIC_CONSTANT           5
  696. #define QUARTIC_CONSTANT           6
  697. #define SPHERE_CONSTANT            7
  698. #define PLANE_CONSTANT             8
  699. #define TRIANGLE_CONSTANT          9
  700. #define SMOOTH_TRIANGLE_CONSTANT  10  
  701. #define CSG_INTERSECTION_CONSTANT 11   
  702. #define CSG_UNION_CONSTANT        12
  703. #define CSG_DIFFERENCE_CONSTANT   13
  704. #define COMPOSITE_CONSTANT        14
  705. #define TEXTURE_CONSTANT          15
  706.  
  707. struct Constant_Struct
  708.    {
  709.    int Identifier_Number;
  710.    CONSTANT Constant_Type;
  711.    char *Constant_Data;
  712.    };
  713.  
  714. struct Chunk_Header_Struct {
  715.    long name;
  716.    long size;
  717.    };
  718.  
  719. struct Data_File_Struct {
  720.    FILE *File;
  721.    char *Filename;
  722.    int Line_Number;
  723.    };
  724.  
  725. struct complex_block {
  726.    DBL r, c;
  727.    };
  728.  
  729. #define READ_MODE 0
  730. #define WRITE_MODE 1
  731. #define APPEND_MODE 2
  732.  
  733. struct file_handle_struct {
  734.    char *filename;
  735.    int  mode;
  736.    int width, height;
  737.    int buffer_size;
  738.    char *buffer;
  739.    FILE *file;
  740.    char *(*Default_File_Name_p) PARAMS((void));
  741.    int  (*Open_File_p) PARAMS((struct file_handle_struct *handle,
  742.            char *name, int *width, int *height, int buffer_size,
  743.            int mode));
  744.    void (*Write_Line_p) PARAMS((struct file_handle_struct *handle,
  745.            COLOUR *line_data, int line_number));
  746.    int  (*Read_Line_p) PARAMS((struct file_handle_struct *handle,
  747.            COLOUR *line_data, int *line_number));
  748.    void (*Read_Image_p) PARAMS((IMAGE *Image, char *filename));
  749.    void (*Close_File_p) PARAMS((struct file_handle_struct *handle));
  750.    };
  751.  
  752. typedef struct file_handle_struct FILE_HANDLE;
  753.  
  754. #define Default_File_Name(h) ((*((h)->Default_File_Name_p)) ())
  755. #define Open_File(h,n,wd,ht,sz,m) ((*((h)->Open_File_p)) (h,n,wd,ht,sz,m))
  756. #define Write_Line(h,l,n) ((*((h)->Write_Line_p)) (h, l, n))
  757. #define Read_Line(h,l,n) ((*((h)->Read_Line_p)) (h, l, n))
  758. #define Read_Image(h,i) ((*((h)->Read_Image_p)) (h, i))
  759. #define Close_File(h) ((*((h)->Close_File_p)) (h))
  760.